<%@ page contentType="text/html; charset=UTF-8" language="java"%>
<%@ taglib prefix="limits" uri="/WEB-INF/tld/limits.tld"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>投票管理</title>
<link rel="stylesheet" type="text/css"	href="../static/js/themes/defalut.css">
<link rel="stylesheet" type="text/css"	href="../static/js/themes/public.css">
<link rel="stylesheet" type="text/css"	href="../static/js/themes/ddspstyle.css">
<link rel="stylesheet" type="text/css"	href="../static/js/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"	href="../static/js/themes/icon.css">
<link href="../static/css/uploadify.css" rel="stylesheet" type="text/css"/>


<script type="text/javascript" src="../static/js/jquery.min.js"></script>
<script type="text/javascript" src="../static/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../static/js/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="../static/js/index.js"></script>
<script src="../static/js/jquery.uploadify.js" type="text/javascript"></script>
<%
	String para =request.getParameter("f_cc_id");
	int f_cc_id = 0;
	if(para != null)
	f_cc_id = Integer.valueOf(para);
%>


<script type="text/javascript">
		var queryParams;
		var id_=<%=f_cc_id%>;
		function EasyuiDatagrid() {
			$("#easyui-datagrid").datagrid({
				url:"select_vote_user.do?f_avu_contentid="+id_,
				nowrap: true,
				striped: true,
				border: false,
				fit: true,
				rownumbers:true,
				queryParams: getGueryParams(),
				columns: [[
					{field:'id',checkbox:true},
					{field:'f_avu_serverid',title:'业务帐号',align:'center',width:70},
					{field:'f_avu_contentid',title:'投票目标',align:'center',width:70},
					{field:'f_avu_votenum',title:'用户票数',align:'center',width:50},
					{field:'f_avu_activityid',title:'活动编号',align:'center',width:50},
					{field:'f_avu_source',title:'投票来源',align:'center',width:50},
					{field:'f_avu_type',title:'投票类型',align:'center',width:70,
						formatter:function(value,row,index) {
							var sex = "未知";
							if(value==1){
								sex="增加票数";
							} else if(value==2){
								sex="减投票数";
							}else if(value==3){
								sex="系统赠送票数";
							}
							return sex;
						}	
					},	
					{field:'f_avu_memo',title:'备注',align:'center',width:70},
					{field:'f_avu_obligate1',title:'预留字段',align:'center',width:70},
					{field:'f_avu_obligate2',title:'预留字段2',align:'center',width:70},
					{field:'f_avu_udate',title:'更新时间',align:'center',width:70},
					{field:'f_avu_cdate',title:'创建时间',align:'center',width:70},
					
				]],
				singleSelect:false,
				pagination:true,
				pageList:[10,20,30,40,50,1000,10000],
				pageSize:10,
				toolbar: '#toolbar',
				
				onExpandRow: function(index,row){
				
				},
				onSelect: function(rowIndex,rowData) {
					
				},
				onUnselect: function(rowIndex,rowData) {
					
				},
				onCheckAll: function(rowIndex,rowData) {
					
				},
				onUncheckAll: function(rowIndex,rowData) {
				
				},
				onLoadSuccess: function(data) {
					if(data.total==-1) {
						$.messager.defaults={ok:"确定",cancel:"取消"};
						$.messager.confirm('提示', '用户尚未登录,请登录', function(r){
						if (r){
						    window.parent.location.href='/login.do';
						    return false;
						}});
					}
				}
			});
		}
	
		function getGueryParams(){
			return {
				f_avu_serverid:$("#f_avu_serverid").val(),
				f_avu_activityid:$("#f_avu_activityid").val()
			};
		}
		
		$(function(){
			if(id_==0){
				$.messager.alert('提示', "未获得内容id!!!", 'info', function() {
					$.messager.progress('close');
				});
				return;	
			}
			new EasyuiDatagrid();
			gotoSearch = function(){
				$("#easyui-datagrid").datagrid('reload',getGueryParams());
			};
			
			onClickBtnDelete = function(id){
				$.messager.confirm('确定删除演职人员','确定删除演职人员么?',function(r){
					if(r){
						app_ajax('delete_cast.do?f_cast_id='+id,
						'',
						function(msg){
							if(msg.success) {
								alert("删除成功!");
								if (checkAjaxRequestValidity(msg)) {
									gotoSearch($('#easyui-treegrid'));
								}
							} else {
								alert("删除异常，请联系管理员");
								if($.isFunction(window.showMessager)){
									window.showMessager(msg.resultTitle,msg.result);
								}
							}
						}
						);
					}
				});
			};
		});
		
		function SubgridTabOnSelect(title,index){
			setTimeout(function(){
				$("#easyui-datagrid").datagrid('fixDetailRowHeight',index);
			},300);
			setTimeout(function(){
				$("#easyui-datagrid").datagrid('fixDetailRowHeight',index);
			},3000);
	    }
		
		function exportExcel(){
			$.messager.confirm('导出','确定导出内容么?',function(r){
				if(r){
					var curPage= $('#easyui-datagrid').datagrid("getPager").data("pagination").options.pageNumber;
					var pageSize= $('#easyui-datagrid').datagrid("getPager").data("pagination").options.pageSize;
					var f_avu_serverid=$('#f_avu_serverid').textbox('getValue')
					var f_avu_activityid=$('#f_avu_activityid').textbox('getValue')
					var url="vote_excel.do?f_avu_contentid="+id_+"&f_avu_serverid="+f_avu_serverid+"&f_avu_activityid="+f_avu_activityid+"&page="+curPage+"&rows="+pageSize;
					window.open(url);
				}
			});
		}
		function load(){
			$(".datagrid-row-expander datagrid-row-expand").attr("display","none"); 
		}
		
		
		function onpress(){
			var event=arguments.callee.caller.arguments[0]||window.event;//消除浏览器差异
	   		  	if (event.keyCode == 13){  
	      			gotoSearch($('#easyui-treegrid'));
	    		}
		}
		function updatecast(){
			var selections = $("#easyui-datagrid").datagrid('getSelections');
			if(selections==null){
				$.messager.alert('提示', "您未选择人物", 'info', function() {
					$.messager.progress('close');
				});
				return;	
			}
			var ids="", idList="";
			for(var i=0;i<selections.length;i++) {
				var id = selections[i].f_cast_name;
				ids+=id+",";
				idList+=selections[i].f_cast_id+",";
			}
			if(ids!=""){
				ids = ids.substring(0, ids.lastIndexOf(','));  
			}
			if(idList!=""){
				idList = idList.substring(0, idList.lastIndexOf(','));  
			}
			if(id_==3){
				
				window.parent.document.getElementById("f_cc_director").value=ids;
				console.log(3+"||"+window.parent.document.getElementById("f_cc_director").value);
			}else if(id_==2){
				
				window.parent.document.getElementById("f_cast_id").value=idList;
				window.parent.document.getElementById("f_cc_actors").value=ids;
				console.log(2+"||"+window.parent.document.getElementById("f_cc_actors").value);
			}else if(id_==1){
				window.parent.document.getElementById("f_cc_screenwriter").value=ids;
				console.log(1+"||"+window.parent.document.getElementById("f_cc_screenwriter").value);
			}
			
	         //window.parent.document.getElementById("model_list").style.display="none";
	         parent.$('#cast_list').dialog('close')
		}
		
	</script>
</head>
<body onload="load();" style="width: 100%;">
	<input type="hidden" id="sessionId" value="${pageContext.session.id}" />
	<table id="easyui-datagrid" title="投票流水列表"></table>
	<div id="toolbar" class="easyui_datagrid_toolbar" style="">
		<div class="easyuiSearch">
			<form onsubmit="return false;" method="post">
				<table cellspacing="0" cellpadding="0" width="100%">
					<tr>
						<td align="right" width="20%">业务账号：</td>&nbsp;
						<td align="left" width="10%">
							<input  class="easyui-textbox" type="text"  name="f_avu_serverid" id="f_avu_serverid"  onkeydown="onpress();" />
						</td>
					
						<td align="right" width="20%">活动编号：</td>
						<td align="left" width="10%">
							<input class="easyui-textbox" name="f_avu_activityid" 	id="f_avu_activityid"  onkeydown="onpress();" />
						</td>
						<td align="right" width="25%">
							<limits:uiAuth url="select_vote_user.do">
								<a href="javascript:void(0);" class="easyui-linkbutton"
									data-options="iconCls:'icon-search', plain:true"
									onclick="gotoSearch($('#easyui-datagrid'))">查询</a>
							</limits:uiAuth>
						</td>
						<td align="right" width="25%">
							<limits:uiAuth url="select_vote_user.do">
										<a href="javascript:void(0);" class="easyui-linkbutton"
										data-options="iconCls:'icon-save', plain:true"
										onclick="javascript:exportExcel()">导出Excle</a>
							</limits:uiAuth>
						</td>
						
					</tr>
				</table>
			</form>
		</div>
		<div style="margin-bottom: 5px">
		</div>
	</div>
	<div id="dlg" class="easyui-dialog"
		style="width: 950px; height: 600px; padding-top: 0px;"
		data-options="title:'内容管理', iconCls:'icon-save',modal:true,closed:true,buttons:'#dlg_buttons'">
		<iframe scrolling="auto" frameborder="0"
			style="width: 100%; height: 99%;"></iframe>
	</div>
	
	

<script type="text/javascript">
</script>
	
	
	
</body>
</html>